﻿@model CubicFWNet.Data.Models.PurchaseCompose
@*@model IEnumerable<ProductTechnologyView>*@
@{
    //ViewBag.Title = "价格核算";
    var operationName = ViewBag.OperationName;
    var operationTime = ViewBag.OperationTime;
    var pro = ViewBag.Product as CubicFWNet.Data.Models.Product;
    var customer = ViewBag.Customer as CubicFWNet.Data.Models.Customer;
}
<section class="content-header">
    <h1>
        采购审核
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("PurchaseQuery", "PurchasePerson")">采购查询</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                @if (Model != null)
                {
                    <form class="form-horizontal" id="frmedit" action="@Url.Action("UpdatePurchase", "PurchasePerson")" method="post">
                        <div class="box-body">
                            <input type="hidden" id="Id" name="Id" value="@Model.Id" />
                            <input type="hidden" id="ApplyId" name="ApplyId" value="@Model.ApplyId" />
                            <input type="hidden" id="ApplyTime" name="ApplyTime" value="@Model.ApplyTime" />
                            <input type="hidden" id="Type" name="Type" value="@Model.Type" />

                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">产品名称</label>
                                <div class="col-sm-9">
                                    @if (Model.Type == 1 && pro != null)
                                    {
                                        <input type="text" class="form-control" id="ProductName" name="ProductName" value="@pro.Name" readonly="readonly" />
                                    }
                                    else
                                    {
                                        <input type="text" class="form-control" id="PurchaseName" name="PurchaseName" value="@Model.ProductName" readonly="readonly" />
                                    }
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">采购单号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="Number" name="Number" value="@Model.Number" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">供应商</label>
                                <div class="col-sm-9">
                                    @if (customer != null)
                                    {
                                        <input type="text" class="form-control" id="SupplierName" name="SupplierName" value="@customer.Name" readonly="readonly" />
                                    }
                                    else
                                    {
                                        <input type="text" class="form-control" id="SupplierName" name="SupplierName" value="无供应商" readonly="readonly" />
                                    }
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">采购数量</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="Amount" name="Amount" value="@Model.Amount" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">成本价</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="CostPrice" name="CostPrice" value="@Model.CostPrice" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-6" style="display: none">
                                <label class="col-sm-3 control-label">实际价格</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="ActualPrice" name="ActualPrice" value="@Model.CostPrice" readonly="readonly" />
                                </div>
                            </div>


                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">备注</label>
                                <div class="col-sm-9">
                                    <textarea class="form-control" rows="3" name="Memo" id="Memo" readonly="readonly">@Model.Memo</textarea>
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label for="operationName" class="col-sm-3 control-label">操作人</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationName" name="operationName" value="@operationName" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="operationTime" class="col-sm-3 control-label">日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationTime" name="operationTime" value="@operationTime" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="box-footer" style="width: 80%; margin-left: 20px;">
                            <a role="button" href="javascript:void(0)" class="btn btn-primary submitbtn" onclick="formsubmit(1)">通过</a>
                            <a role="button" href="@Url.Action("PurchaseQuery", "PurchasePerson")" class=" btn btn-primary submitbtn">返回</a>
                            <div class="text-red" style="margin-top:20px;font-weight:bold">下一步：采购管理-->采购查询</div>
                        </div>
                    </form>
                }
            </div>
        </div>
    </div>
</section>
<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

<style>
    .has-error {
        border-color: #dd4b39;
        box-shadow: none;
    }
</style>


@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#frmedit").validate({
                submitHandler: function (form) {
                    var postData = $(form).formSerialize();
                    $.submitForm({
                        url: $(form).attr("action"),
                        param: postData,
                        success: function () {
                            $.modalAlert("操作成功", "success");
                            window.location.href = '@Url.Action("PurchaseQuery", "PurchasePerson")';
                        }
                    });
                }
            });
        });

        function formsubmit(t) {

            $("#frmedit").submit();
        }

        $(".okeydown").on("keyup", function () {
            var value = $(this).val();
            if (isNaN(value) || value == "" || value == "Infinity" || value == "NaN") {
                $(this).addClass("has-error");
            } else {
                $(this).removeClass("has-error");
            }
        });


        $(".okeydown").on("keydown", function () {
            var k = event.keyCode;
            if ((k <= 57 && k >= 48) || (k <= 105 && k >= 96) || (k == 8) || (k == 110) || (k == 190)) {
                return true;
            } else {
                return false;
            }
        });

    </script>
}